import React from "react";
import {Col, List, Row, Table, Tag} from 'antd';
import IconFont4 from "../../util/autoIcon/notice";
import {Link} from "react-router-dom";
import './Notice.css'
import IconFont2 from "../../util/autoIcon/file";
import API from '../../api/api'
import IconFont5 from "../../util/autoIcon/activity_newly";


export default class Notice extends React.Component{

    data = [];

    isNotify = (record)=>{
        let currentDate = new Date()
        let date = new Date(record.createTime);
        if(record.new!="" && record.new!=null){
            date.setDate(date.getDate()+Number.parseInt(record.new));
            if(currentDate<=date){
                return <img src="/new_red_1.png" style={{display:"inlineBlack",width:"100%"}}/>
                // return <IconFont5 id="icon5" style={{height:"100%",float:"right"}} type="icon-new" />
            }
        }
    }

    render() {
        this.data = API.previewNoticeList()
        return (
            // <Table
            //     size="small"
            //     columns={columns}
            //     dataSource={data}
            //     bordered
            //     title={() => <span style={{fontSize:"1.6rem",fontWeight:"bold"}}><IconFont4 type={"icon-tongzhigonggao"} /> 最新公告</span>}
            // />
            <>
                <List
                    // grid={{
                    //     gutter: 24,
                    //     xs: 1,
                    //     sm: 2,
                    //     md: 3,
                    //     lg: 3,
                    //     xl: 2,
                    //     xxl: 3,
                    // }}
                    className="notice-list"
                    size="small"
                    header={
                        <Link to="/eip/table/notice">
                            <span className="folder-ellipsis" style={{color:"black",fontSize:"1rem",fontWeight:"bold"}}><IconFont4 type={"icon-tongzhigonggao"} /> 最新公告</span>
                        </Link>
                    }
                    footer={<Link to="/eip/table/notice">查看更多</Link>}
                    bordered
                    dataSource={this.data}
                    renderItem={item => (
                        <List.Item >
                            <Row id="resourceRow" gutter={3}>
                                <Col style={{float:"left",width:'64%'}}>
                                    <Link to={`/eip/file/notice/${item.key}`}>
                                        <span className="folder-ellipsis" title={item.name} style={{float:"left"}}>{item.name}</span>&nbsp;&nbsp;

                                    </Link>
                                </Col>
                                <Col style={{textAlign: "right",width:'7%'}}  >
                                    {this.isNotify(item)}
                                </Col>
                                <Col style={{textAlign: "right",width:'27%'}}>
                                    <span className="folder-ellipsis" title={item.createTime}>{item.createTime}</span>
                                </Col>
                            </Row>
                        </List.Item>
                    )}
                />

            </>
        );
    }
}
